package com.talent.study.chain;

/**
 * @Author: hszhou
 * @Date: 2025/5/10 15:05
 * @Description: 必须描述类做什么事情, 实现什么功能
 */
public abstract class AbstractHandler {

    private AbstractHandler handler;

    public void setHandler(AbstractHandler handler){
        this.handler = handler;
    }

    public void handleRequest(Request request) {
        if(this.canHandle(request)){
            this.handler(request);
        }else if(handler!=null){
            handler.handleRequest(request);
        }
    }

    protected abstract boolean canHandle(Request request);
    protected abstract void handler(Request request);
}
